<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%     
	String path = request.getContextPath();     
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";     
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查看需求</title>
<base href="<%=basePath%>" />
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" href="<%=basePath%>/js/uploadify/css/uploadify.css" type="text/css"></link>
<link type="text/css" href="js/mcdropdown/css/jquery.mcdropdown.css" rel="stylesheet" media="all" />
<script type="text/javascript" src="js/mcdropdown/lib/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/mcdropdown/lib/jquery.mcdropdown.js"></script>
<script type="text/javascript" src="js/mcdropdown/lib/jquery.bgiframe.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/uploadify/jquery.uploadify-3.1.min.js"></script>
<script language="JavaScript" type="text/javascript" src="<%=basePath%>js/my97/WdatePicker.js" defer="defer"></script>
<style type="text/css">
fieldset,legend,form,table,tr,td,textarea {margin: 0;padding: 0}
form label {font-weight: bold;}
table {margin: 10px 10px}
td {line-height: 25px;}
input[type="text"] {width: 250px;}
input[type="password"] {width: 250px;}
input[type="textarea"] {width: 250px;}
.divlist {float: left;height: 100%;width: 60%;}
.divcomment {float: left;height: 100%;width: 40%;}
.word{line-height: 120%;word-break:break-all}
</style>
<script type="text/javascript">
	   //返回列表页面
	   function btn_return(){
		     var qs = $("#qs").val();
	    	window.location.href="<%=basePath%>depreq/list.do?" + qs;
	   }
	   $(document).ready(function(){
		   //回复信息----------------------------------------------------------------------
			 $('#commentForm').submit(function(){
			   	  if(isEmpty($("#comment").val())) { alert("回复内容不能为空！"); return false; }
	              $.ajax({
	                  url: "<%=basePath%>myreq/comment.do",   // 提交的页面
	                  data: $('#commentForm').serialize(),    // 从表单中获取数据
	                  type: "POST",                           // 设置请求类型为"POST"，默认为"GET"
	                  dataType: 'json',
	                  error: function(XMLHttpRequest, textStatus, errorThrown) {
	                        alert(XMLHttpRequest.status);
	                  },
	                  success: function(data) {
	                  	if(data.code == 1) {
		                  		 $("#allComment").prepend(
						    			   "<table style=' width: 83%'>"
						    			 +"   <tr>"
						    			 +"      <td ><label>"+ data.createTime+"</label>"
						    			 +"      &nbsp;&nbsp;&nbsp; <font color='red'>"+$("#usercnname").val()+"</font></td>"
						    			 +"   </tr>"
						    			 +"   <tr>"
						    			 +"      <td class='word' >	<span style='color:#00A;'>"+$("#comment").val()+"</span></td>"
						    			 +"   </tr>"
						    			 +" </table>"
						    	  );
								 $('#comment').val('');
	                      }}
	                  });
	              return false;
	          });
		   });
		     //回复信息结束----------------------------------------------------------------------
	</script>
</head>
<body>
	<div class="divlist">
		<div style="width:98%">
			<fieldset>
				<legend>基本信息：</legend>
					<table style="table-layout:fixed;width:95%">
						<tr>
							<td width="18%"><label>标题：</label> </td>
							<td colspan="3">  <input id="qs" name="qs" type="hidden" value="${qs}"/>
							   ${req.title}
							</td>
						</tr>
						<tr>
							 <td><label for="status">负责方：</label></td>
							 <td colspan="3">
					               <c:forEach items="${sList}" var="s" varStatus="status">
									       <c:if test="${req.startStatus == s.value}">
									          ${s.name}
									       </c:if>
								   </c:forEach>
					         </td>        
						</tr>
						<tr>
							<td width="15%"><label >发起人：</label></td>
							<td width="35%">
							 ${req.cnName}
							</td>
							<td width="15%"><label >当前状态：</label></td>
							<td width="35%">
						       <c:forEach items="${itemList}" var="item" varStatus="status">
							       <c:if test="${req.status == item.value}">
							         ${item.name}
							       </c:if>
							   </c:forEach>
							</td>
						</tr>
						<tr>
							<td><label >发起时间：</label></td>
							<td>
							   <fmt:formatDate value="${req.createTime}" type="both"	dateStyle="medium" timeStyle="medium" />
							</td>
							<td><label >期望完成时间：</label></td>
							<td>
							   <fmt:formatDate value="${req.expPerTime}" type="both"	dateStyle="medium" timeStyle="medium" /> 
							</td>
						</tr>
						<tr>
							<td><label>需求内容：</label> </td>
							<td colspan="3"> 
							    <textarea name="content" id="content" cols="60" rows="8" disabled="disabled"><c:out value="${req.content}"></c:out></textarea>
							</td>
						</tr>
						<c:forEach items="${attList}" var="att" varStatus="status">
						  <tr>
						    <c:if test="${status.count == 1}">
							   <td><label>相关文件：</label> </td>
							</c:if>
							<c:if test="${status.count!=1}">
							   <td></td>
							</c:if>
							<td colspan="3"> 
							   <a href="<%=basePath%>myreq/download.do?fileName=${att.name}&path=${att.path}">${att.name}</a>
							</td>
						  </tr>
						</c:forEach>
					</table>
			</fieldset>
		</div>
		<div id="uploadDiv" style="width:98%">
			<fieldset>
				<legend>处理情况：</legend>
					<table style="table-layout:fixed;width:95%">
						<c:if test="${req.reqType != null}">
							<tr>
								<td width="18%"><label>类别：</label> </td>
								<td width="32%"> 
					                <c:forEach var="t" items="${typeList}">
					                   <c:if test="${t.id == req.reqType}">
					                       ${t.name}
					                   </c:if>
					                </c:forEach>
								</td>
								<td width="18%"><label>负责人：</label> </td>
								<td width="32%"> 
								    ${principal}
								</td>
							</tr>
						</c:if>
						<tr>
							<td width="18%"><label>预计开始时间：</label></td>
							<td>
							    ${req.perStaTime}
							</td>
							<td width="18%"><label>预计结束时间：</label></td>
							<td>
							    ${req.perEndTime}
							</td>
						</tr>
							<c:if test="${req.revokeReason != null}">
								 <tr>
									<td valign="top"><label>撤销理由：</label></td>
									<td colspan="3">
									   <textarea rows="8" cols="60" disabled="disabled">${req.revokeReason}</textarea>
									</td>
								 </tr>
							</c:if>
							<c:if test="${req.notPass != null}">
								 <tr>
									<td width="17%" valign="top"><label>未通过审核理由：</label></td>
									<td colspan="3">
									   <textarea rows="8" cols="60" disabled="disabled">${req.notPass}</textarea>
									</td>
								 </tr>
					    	</c:if>
							<c:if test="${req.refuseReason != null}">
								 <tr>
									<td valign="top"><label>拒绝理由：</label></td>
									<td colspan="3">
									   <textarea rows="8" cols="60" disabled="disabled">${req.refuseReason}</textarea>
									</td>
								 </tr>
							</c:if>
							<c:if test="${req.inHangDesc != null}">
								 <tr>
									<td valign="top"><label>处理中描述：</label></td>
									<td colspan="3">
									   <textarea rows="8" cols="60" disabled="disabled">${req.inHangDesc}</textarea>
									</td>
								 </tr>
							</c:if>
							<c:if test="${req.handedDesc != null}">
							     <tr>
									<td valign="top"><label>完成时间：</label></td>
									<td colspan="3">
									   ${req.finishTime}
									</td>
								 </tr>
								 <tr>
									<td valign="top"><label>已处理描述：</label></td>
									<td colspan="3">
									   <textarea rows="8" cols="60" disabled="disabled">${req.handedDesc}</textarea>
									</td>
								 </tr>
							</c:if>
				</table>
			</fieldset>
			<input type="button" id="btn_back" 	value="返回" onclick="btn_return();" style="width: 80px;" />
		</div>
	</div>
	  <div class="divcomment">
		<fieldset >
			<legend>交流板</legend>
		    <form id="commentForm" >
				<table style="width: 85%">
					<tr>
						<td ><textarea name="comment" id="comment" cols="40" rows="5"></textarea></td>
					    <td valign="bottom">
					      <input type="hidden" name="objectId" id="objectId" value="${req.id}">
					      <input type="submit" id="send" name="send" value="发表" />
					      <input type="hidden"  id="usercnname" value="${sessionScope.usercnname}">
					    </td>
					</tr>
				</table>
		    </form>
			<div id="allComment">
			   <c:forEach  items="${comList}" var="com">
					<table>
						<tr>
							<td>
								<label for="project">
								  <fmt:formatDate value="${com.createTime}" type="both"	dateStyle="medium" timeStyle="medium" />
								</label>
								&nbsp;&nbsp;&nbsp;
								<font color="red">${com.userCnname}</font>
							</td>
						
						</tr>
						<tr>
							<td class="word">
								<span style="color:#00A;">${com.content}</span>
							</td>
						</tr>
					</table>
				</c:forEach>
			</div>
		</fieldset>
	</div>
</body>
</html>